package com.yuexun.beilunpatient.ui.registration.adapter;

import android.widget.AbsListView;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.yuexun.beilunpatient.R;
import com.yuexun.beilunpatient.ui.registration.bean.AppointmentDocData;

import org.kymjs.kjframe.widget.AdapterHolder;
import org.kymjs.kjframe.widget.KJAdapter;

import java.util.Collection;

/**
 * Created by chenss on 2018/10/18.
 */
public class RegistrationDocAdapter extends KJAdapter<AppointmentDocData> {

    public RegistrationDocAdapter(AbsListView view, Collection<AppointmentDocData> mDatas, int itemLayoutId) {
        super(view, mDatas, itemLayoutId);
    }

    @Override
    public void convert(AdapterHolder helper, AppointmentDocData item, boolean isScrolling, int position) {
        super.convert(helper, item, isScrolling, position);

        if(item.getDoctor_name().isEmpty()){
            helper.setText(R.id.doctor_name, item.getDepartment_name());
        }else{
            helper.setText(R.id.doctor_name, item.getDoctor_name());
        }
        if(item.getDoctor_title().isEmpty()){
            helper.setText(R.id.doctor_dep, "");
        }else{
            helper.setText(R.id.doctor_dep, "[" + item.getDoctor_title() + "]");
        }
        helper.setText(R.id.doctor_hospital, item.getHospital_name());
        ImageView doctor_pic = (ImageView) helper.getView(R.id.doctor_pic);
        Glide.with(mCxt).load(item.getDoctor_photo()).into(doctor_pic);
    }
}
